import type { BasicColumn, FormSchema } from '/@/components/Table';
import { useUserStore } from '/@/store/modules/user';
import { useI18n } from '/@/hooks/web/useI18n';
const { t } = useI18n();
const useCommonStore = useUserStore();

export const dataColumns: BasicColumn[] = [
  {
    title: t('routes.table.dictionaryManagement.dataLabel'),
    dataIndex: 'resourceName',
    width: 180,
  },
  {
    title: t('routes.table.dictionaryManagement.status'),
    dataIndex: 'isStop',
    width: 180,
    slots: { customRender: 'isStop' },
  },
  {
    title: t('routes.table.dictionaryManagement.remark'),
    dataIndex: 'description',
    width: 180,
  },
];

export const dataSearchFormSchema: FormSchema[] = [
  {
    label: t('routes.table.dictionaryManagement.dataLabel'),
    field: 'resourceName',
    component: 'Input',
    colProps: { span: 8 },
  },
  {
    label: t('routes.table.dictionaryManagement.status'),
    field: 'isStop',
    component: 'Select',
    colProps: { span: 8 },
    componentProps: {
      options: [
        {
          label: t('common.enabled'),
          value: true,
        },
        {
          label: t('common.disabled'),
          value: false,
        },
      ],
    },
  },
];

export const dataFormSchema: FormSchema[] = [
  {
    label: t('routes.table.dictionaryManagement.code'),
    field: 'id',
    show: false,
    component: 'Input',
  },
  {
    label: t('routes.table.dictionaryManagement.codePlaceholder'),
    field: 'typeID',
    show: false,
    component: 'Input',
  },
  {
    label: t('routes.table.dictionaryManagement.dictionaryType'),
    field: 'dictType',
    required: true,
    component: 'Input',
    dynamicDisabled: ({ values }) => !!values.dictType,
  },
  {
    label: t('routes.table.dictionaryManagement.dataLabel'),
    field: 'resourceName',
    required: true,
    component: 'Input',
  },
  {
    label: t('routes.table.dictionaryManagement.status'),
    field: 'isStop',
    component: 'Select',
    defaultValue: true,
    componentProps: {
      options: [
        {
          label: t('common.enabled'),
          value: true,
        },
        {
          label: t('common.disabled'),
          value: false,
        },
      ],
    },
  },
  {
    label: t('routes.table.dictionaryManagement.remark'),
    field: 'description',
    component: 'InputTextArea',
    defaultValue: '',
  },
  {
    label: t('routes.table.dictionaryManagement.cost'),
    field: 'costs',
    show: false,
    component: 'Input',
    defaultValue: 0,
  },
  {
    label: t('routes.table.dictionaryManagement.resourceAssociation'),
    field: 'resourceAbout',
    show: false,
    component: 'Input',
    defaultValue: '',
  },
  {
    label: t('routes.table.dictionaryManagement.parentDataCode'),
    field: 'parentResourceid',
    show: false,
    component: 'Input',
    defaultValue: '',
  },
  {
    label: t('routes.table.dictionaryManagement.creator'),
    field: 'founder',
    show: false,
    component: 'Input',
    defaultValue: useCommonStore.userInfo?.userId,
  },
];
